<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>修改页面</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/statics/component/pear/css/pear.css" />
	</head>
	<body>
<%--	${pageContext.request.contextPath}/user/update--%>
		<form class="layui-form" action="" >
			<div class="mainBox">
				<div class="main-container">
					<div class="layui-form-item">
						<label class="layui-form-label">id</label>
						<div class="layui-input-block">
							<input type="text" name="roleId"  value="${requestScope.sysRole.roleId}" lay-verify="title" autocomplete="off"
								   placeholder="请输入Id" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">角色名称</label>
						<div class="layui-input-block">
							<input type="text" name="roleName"  value="${requestScope.sysRole.roleName}" lay-verify="title" autocomplete="off"
								placeholder="请输入标题" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">角色权限</label>
						<div class="layui-input-block">
							<input type="text" name="roleKey" value="${requestScope.sysRole.roleKey}" lay-verify="title" autocomplete="off" placeholder="请输入标题"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">角色状态:</label>
						<div class="layui-input-block">
							<input type="radio" name="status" value="0" title="正常" checked>
							<input type="radio" name="status" value="1" title="停用">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">显示顺序</label>
						<div class="layui-input-block">
							<input type="text" name="roleSort" value="${requestScope.sysRole.roleSort}" lay-verify="title"
								autocomplete="off" placeholder="请输入标题" class="layui-input">
						</div>
					</div>
<%--					<div class="layui-form-item">--%>
<%--						<label class="layui-form-label">数据范围:</label>--%>
<%--						<div class="layui-input-block" style="width: 400px">--%>
<%--							<select name="dataScope" lay-filter="aihao">--%>
<%--								<option  value= "${requestScope.sysRole.dataScope == '1' ? "checkbox" : ""}">全部数据权限</option>--%>
<%--								<option  value= "${requestScope.sysRole.dataScope == '2' ? "checkbox" : ""}">自定数据权限</option>--%>
<%--								<option  value= "${requestScope.sysRole.dataScope == '3' ? "checkbox" : ""}">本部门数据权限</option>--%>
<%--								<option  value= "${requestScope.sysRole.dataScope == '4' ? "checkbox" : ""}">本部门及以下数据权限</option>--%>
<%--							</select>--%>
<%--						</div>--%>
<%--					</div>--%>


					<div class="layui-form-item">
						<label class="layui-form-label">删除标志:</label>
						<div class="layui-input-block">
							<input type="radio" name="delFlag" value="${requestScope.sysRole.delFlag == 0 ? 'checkbox' :''}" title="存在" checked>
							<input type="radio" name="delFlag" value="${requestScope.sysRole.delFlag == 1 ? 'checkbox' :''}" title="删除">
						</div>
					</div>

				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="user-save">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="${pageContext.request.contextPath}/statics/component/layui/layui.js"></script>
		<script src="${pageContext.request.contextPath}/statics/component/pear/pear.js"></script>
		<script>


			layui.use(['form', 'jquery'], function() {
				let form = layui.form;
				let $ = layui.jquery;

				form.on('submit(user-save)', function(data) {

					<%--$.post("${pageContext.request.contextPath}/role/update",function (result) {--%>
					<%--	if (result == 1) {--%>
					<%--		layer.msg(result.msg, {--%>
					<%--			icon: 1,--%>
					<%--			time: 1000--%>
					<%--		}, function() {--%>
					<%--			parent.layer.close(parent.layer.getFrameIndex(window--%>
					<%--					.name)); //关闭当前页--%>
					<%--			parent.layui.table.reload("role-table");--%>
					<%--		});--%>
					<%--	} else {--%>
					<%--		layer.msg(result.msg, {--%>
					<%--			icon: 2,--%>
					<%--			time: 1000--%>
					<%--		});--%>
					<%--	}--%>
					<%--});--%>

					$.ajax({
						url: '${pageContext.request.contextPath}/role/update',
						data: data.field,
						dataType: 'json',
						// contentType: 'application/json',
						type: 'post',
						success: function(result) {
							if (result == 1) {
								layer.msg(result.msg, {
									icon: 1,
									time: 1000
								}, function() {
									parent.layer.close(parent.layer.getFrameIndex(window
										.name)); //关闭当前页
									parent.layui.table.reload("role-table");
								});
							} else {
								layer.msg(result.msg, {
									icon: 2,
									time: 1000
								});
							}
						}
					})
					return false;
				});
			});


		</script>
		<script>
		</script>
	</body>
</html>
